package com.zmj.framework.authorization.client;

import com.zmj.framework.authorization.vo.AccessToken;
import com.zmj.framework.response.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author 李飞
 */
@FeignClient(name = "auth-manage-cloud",url = "${feign.client.urls.authUrl}", fallback = AuthorizationClientFallback.class)
public interface AuthorizationClient {

    /**
     * 获取token
     * @param grantType
     * @param clientId
     * @param clientSecret
     * @param code
     * @param redirectUri
     * @return
     */
    @PostMapping(value = "/oauth2/token")
    AccessToken token(@RequestParam("grant_type") String grantType, @RequestParam("client_id") String clientId,
                      @RequestParam("client_secret") String clientSecret, @RequestParam("code") String code,
                      @RequestParam("redirect_uri") String redirectUri);

    /**
     * 刷新token
     * @param grantType
     * @param clientId
     * @param clientSecret
     * @param refresh_token
     * @return
     */
    @PostMapping(value = "/oauth2/token")
    AccessToken refreshToken(@RequestParam("grant_type") String grantType, @RequestParam("client_id") String clientId,
                         @RequestParam("client_secret") String clientSecret, @RequestParam("refresh_token") String refresh_token);

    /**
     * 登出
     * @param token
     * @param tokenTypeHint
     * @param clientId
     * @param clientSecret
     * @return
     */
    @PostMapping(value = "/oauth2/revoke")
    Result logout(@RequestParam("token") String token, @RequestParam("token_type_hint") String tokenTypeHint, @RequestParam("client_id") String clientId,
                  @RequestParam("client_secret") String clientSecret);

}
